package com.oa.api;


import com.github.pagehelper.PageInfo;
import com.oa.oaspccommon.po.User;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * @author zd
 * @date 2021年04月19日 17:20
 */
@FeignClient("oa-spc-system")
public interface UserServiceApi {
    /**
     * 查询所有user
     * @return
     */
    @RequestMapping(value = "/users",method = RequestMethod.GET)
    public List<User> findAll();


    /**
     * 根据id查询
     * @param uid
     * @return
     */
    @RequestMapping(value = "/user",method = RequestMethod.GET)
    public User finfOne(@RequestParam("uid") Integer uid);

    /**
     * 新增
     * @param user
     * @return
     */
    @RequestMapping(value = "/user",method = RequestMethod.POST)
    public Boolean addUser(@RequestBody User user);

    /**
     * 删除
     * @param uid
     * @return
     */
    @RequestMapping(value = "/user",method = RequestMethod.DELETE)
    public Boolean delUSer(@RequestParam("uid") Integer uid);

    /**
     * 修改
     * @param user
     * @return
     */
    @RequestMapping(value = "/user",method = RequestMethod.PUT)
    public Boolean update(@RequestBody User user);


    /**
     * 根据username做模糊查询
     * @param username
     * @return
     */
    @RequestMapping(value = "/user2",method = RequestMethod.GET)
    public List<User> findByLike(@RequestParam("username") String username);


    /**
     * 分页查询
     * @param pageNum
     * @return
     */
    @RequestMapping(value = "/users2",method = RequestMethod.GET)
    //默认访问第一页
    public PageInfo<User> findByPage2(@RequestParam(defaultValue = "1", required = true, value = "pageNum") Integer pageNum);
}
